<?PHP
    /**
    * @brief Class About Mysql
    * @file mysql.lib.php
    * @author Playplus (kimyh@playplus.co.kr)
    * @date 2013-04-10
    * @copyright Copyright (c) 2013, Playplus
    **/

    if (!defined("__PLAYPLUS__")) exit;

    class mysql {
        function conn($host, $user, $pass) {
    		return @mysql_connect($host, $user, $pass);
    	}

        function seldb($database, $connect) {
            @mysql_query(" SET NAMES utf8 ");
    		return @mysql_select_db($database, $connect) or die("ERROR NO : ".mysql_errno()."<br />ERROR MEASSAGE : ".mysql_error());
        }

        function query($sql, $error=TRUE) {
            $result = @mysql_query($sql) or die("QUERY : ".$sql."<br />ERROR NO : ".mysql_errno()."<br />ERROR MEASSAGE : ".mysql_error()."<br />ERROR FILE : ".$_SERVER["PHP_SELF"]);
    		return $result;
        }

        function fetch_array($result) {
            $row = @mysql_fetch_assoc($result);
            return $row;
        }

        function fetch($sql, $error=TRUE) {
            $result = $this->query($sql, $error);
            $row = $this->fetch_array($result);
    		return $row;
        }

        function num_rows($sql, $error=TRUE) {
            $result = $this->query($sql, $error);
    		$row = @mysql_num_rows($result);
    		return $row;
        }

        function free_result($result) {
            return mysql_free_result($result);
        }

        function password($value)
    	{
    		$row = $this->fetch(" SELECT PASSWORD('$value') AS pass ");
    		return $row['pass'];
    	}

        function close($conn) {
            return mysql_close($conn);
        }
    }
?>